package bbs.controller;


import bbs.controller.base.ABaseController;
import bbs.entity.dto.FollowDto;
import bbs.entity.po.Follow;
import bbs.entity.vo.ResponseVO;
import bbs.service.FollowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController("followController")
@RequestMapping({"/follow"})
public class FollowController extends ABaseController {

    @Autowired
    private FollowService followService;

    @RequestMapping({"/followFlag"})
    public ResponseVO followFlag(Follow follow) {
        return getSuccessResponseVO(followService.FollowFlag(follow.getUserId(), follow.getFollowId()));
    }

    @RequestMapping({"/addFollow"})
    public ResponseVO addFollow(String userId, String followId) {
        followService.addFollow(userId, followId);
        ResponseVO vo = new ResponseVO();
        vo.setInfo("关注成功");
        return getSuccessResponseVO(vo);
    }

    @RequestMapping({"/cancelFollow"})
    public ResponseVO cancelFollow(String followId) {
        followService.cancelFollow(followId);
        ResponseVO vo = new ResponseVO();
        vo.setInfo("取关成功");
        return getSuccessResponseVO(vo);
    }
    
    @RequestMapping({"/loadFollowList"})
    public ResponseVO loadFollowList(String followId) {
        ResponseVO vo = new ResponseVO();
        List<Follow> followList = followService.FollowList(followId);
        vo.setData(followList);
        return getSuccessResponseVO(vo);
    }

    @RequestMapping({"/loadUserList"})
    public ResponseVO loadUserList(String userId) {
        ResponseVO vo = new ResponseVO();
        List<FollowDto> followList = followService.UserList(userId);
        vo.setData(followList);
        return getSuccessResponseVO(vo);
    }
}
